package com.platform.core.entity;

import com.platform.comm.constraints.CExport;
import com.platform.comm.constraints.CImport;
import com.platform.comm.validation.groups.Batch;
import com.platform.comm.enums.YnEnum;
import com.platform.enums.CommFlagType;
import com.platform.enums.converters.CommFlagTypeConverter;
import com.platform.validator.UnifiedCode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Table;
import javax.validation.constraints.NotEmpty;
import java.time.LocalDateTime;

/**
 * Description: 组织信息实体类
 *
 * @author lch Created on 2020/1/17
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@Table(name = "ncloud_sys_depart")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SysDepartConfig extends CommConfig {

    private String sheetName = "组织管理";

    private static final long serialVersionUID = 1019983100905062922L;
    /**
     * 组织名称
     */
    @Column(name = "depart_name")
    @NotEmpty(message = "组织名称不能为空",groups = Batch.class)
    @CExport(name = "组织名称")
    @CImport(name = "组织名称")
    private String departName;

    /**
     * 父组织ID
     */
    @Column(name = "depart_parent", length = 36)
    private String parentId;

    /**
     * 组织类型
     */
    @Column(name = "depart_kind", length = 10)
    @NotEmpty(message = "组织类型不能为空",groups = Batch.class)
    @CExport(colNum = "1",name = "组织类型")
    @CImport(colNum = "1",name = "组织类型")
    private String departKind;

    /**
     * 统一社会信用代码
     */
    @Column(name = "dept_unified_code", length = 18)
    @UnifiedCode(message="必须为合法的统一社会信用代码",groups=Batch.class)
    @CImport(colNum = "3",name = "统一社会信用代码")
    private String unifiedCode;

    /**
     * 组织编码
     */
    @Column(name = "depart_code", length = 128)
    @NotEmpty(message = "组织编码不能为空",groups = Batch.class)
    private String departCode;

    /**
     * 组织全称
     */
    @Column(name = "full_name", length = 360)
    @CExport(colNum = "2",name = "组织全称")
    @CImport(colNum = "2",name = "组织全称")
    private String fullName;

    /**
     * 名称路由
     */
    @Column(name = "route_name", length = 1024)
    private String routeName;

    /**
     * 编码路由
     */
    @Column(name = "route_code", length = 512)
    private String routeCode;

    /**
     * 组织层级
     */
    @Column(name = "depart_level")
    private Integer level;

    /**
     * 所属管理域
     */
    @Column(name = "manage_domain", length = 36)
    private String domain;

    /**
     * 行政区划代码
     */
    @Column(name = "region_id", length = 128)
    private String regionId;

    /**
     * 状态
     */
    @Column(name = "status", length = 20)
    @Convert(converter = CommFlagTypeConverter.class)
    private CommFlagType status;
    /**
     * 状态标志
     */
    @Column(name = "delflag")
    private YnEnum delFlag;

    /**
     * 排序编号
     */
    @Column(name = "depart_sort")
    private Integer sortNum;

    /**
     * 备注
     */
    @Column(name = "remark", length = 512)
    private String remark;

    /**
     * 批量导入ID
     */
    @Column(name = "import_id", length = 36)
    private String importId;

    /**
     * 批量导入状态
     */
    @Column(name = "import_check_flag", length = 10)
    private String importCheckFlag;

    /**
     * 批量导入错误信息
     */
    @Column(name = "check_err_msg", length = 512)
    private String checkErrMsg;

    /**
     * 首次登录系统时间
     */
    @Column(name = "first_login_date", length = 128)
    private LocalDateTime firstLoginDate;

    /**
     * 创建时间
     */
    @Column(name = "create_date", nullable = false, updatable = false)
    private LocalDateTime createDate;


    /**
     * 修改时间
     */
    @Column(name = "update_date")
    private LocalDateTime updateDate;


    @Column(name = "id", length = 36)
    private String id;
}
